home *** CD-ROM | disk | FTP | other *** search
- Path: anvil.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Pointer arithmetic
- Date: 28 Feb 1996 16:37:25 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4h2sg5INNdg3@anvil.ugrad.cs.ubc.ca>
- References: <4h2r55$er@s3.iway.fr>
- NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
-
- In article <4h2r55$er@s3.iway.fr>,
- Pascal Terracol <assetsto@pratique.fr> wrote:
- > Hello,
- >
- >this sample code have been correctly working on a pc 80286 processor
- >
- >I put it on a mac and the pointers seems to act differently...
- >any idea about that ?
- >
- >
- > int size, n1, n2 ;
- > Point *p_debut, *p1, *p2 ; /* "vecteur" de translation des adr */
- >
- >...
- >
- > n1 = (int) (l->p1)/sizeof(Point) ;
- > n2 = (int) (l->p2)/sizeof(Point) ;
- >
- > p1 = p_debut + n1 ;
- > p2 = p_debut + n1 ;
-
- The declaration for l is missing. It looks like a pointer to a structure, since
- you are using it with the -> operator to access members p1 and p2, but what is
- that structure with members p1 and p2? It's a little unusual to be _dividing_
- by the size of a structure. There are few contexts in which this will yield
- correct behavior. It can tell you how many structures will fit into a given
- array of characters, provided the array meets alignment restrictions (e.g. it
- comes from malloc()). The size of the Point structure will quite certainly
- differ between the 80286 and the Mac environment.
-
- --
-
-